package com.mgq.juc.design.singleton;

public class Singleton {
    //读屏障
   private volatile static Singleton singleton=null;
    private Singleton() {
    }
    public static Singleton getInstance(){
        if (singleton == null) {
            synchronized (Singleton.class) {
                if (singleton == null) {
                    singleton = new Singleton();
                    //写屏障
                }
            }
        }
        return singleton;
    }
}
